package com.neusoft.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.neusoft.mapper.base.AppointmentMapper;
import com.neusoft.model.AppointmentsModel;
import com.neusoft.model.BooksModel;
import com.neusoft.model.entity.Appointment;
import com.neusoft.model.entity.AppointmentExample;
import com.neusoft.model.entity.BooksExample;
import com.neusoft.model.vo.BooksModelVO;
import com.neusoft.service.AppointmentService;

@Service
public class AppointmentServiceImpl implements AppointmentService{

	@Autowired
	private AppointmentMapper appointmentMapper;
	
	
	
	
	
	
	
	@Override
	public Appointment findAppointmentByBookID(int id){
//System.out.println("d");
//		appointmentMapper=new AppointmentMapper();
		Appointment appointment=appointmentMapper.selectByPrimaryKey(id);
		return appointment;
	}
 
//	@Override
//	public void updateStatus(int bookingId,int status){
//		Appointment appointment=new Appointment();
//		appointment.setBookingId(bookingId);
////		appointment.set
//		appointmentMapper.updateByPrimaryKey()
//	}
	@Override
	public void insertAppointment(Appointment appointment){
		Appointment appointment2=appointmentMapper.selectByPrimaryKey(appointment.getBookingId());
		if(appointment2==null){
			appointmentMapper.insert(appointment);
		}
	}
	
	@Override
	public AppointmentsModel findAppointmentByUserID(String id){
		AppointmentExample be=new AppointmentExample();
		AppointmentExample.Criteria bec=be.createCriteria();
		AppointmentsModel appointmentsModel=new AppointmentsModel();
		bec.andIdEqualTo(id);
		appointmentsModel.setRows(appointmentMapper.selectByExample(be));
		return appointmentsModel;
	}
	
	@Override
	public void deleteAppointmentByBookID(int id){
		appointmentMapper.deleteByPrimaryKey(id);
	}
	
 

}
